<?php echo $this->Session->flash(); ?>
<script>
    $(document).ready(function() {
        selectDiv();
        $('#tipo').change(function() {
            selectDiv();
        });
    });

    function selectDiv() {
        if ($('#tipo option:selected').val() == 2) {
            $('#juridica').show("slow");
            $('#natural').hide("slow");
            $('#nom_org').attr('disabled', '');
            $('#ide_org').attr('disabled', '');
            $('#RepresentativeCedula').attr('disabled', '');
            $('#RepresentativeNombres').attr('disabled', '');
            $('#RepresentativeApellidos').attr('disabled', '');
            $('#ide_nat').attr('disabled', 'disabled');
            $('#nom_nat').attr('disabled', 'disabled')
        } else {
            if ($('#tipo option:selected').val() == 1) {
                $('#juridica').hide("slow");
                $('#natural').show("slow");
                $('#nom_org').attr('disabled', 'disabled');
                $('#ide_org').attr('disabled', 'disabled');
                $('#RepresentativeCedula').attr('disabled', 'disabled');
                $('#RepresentativeNombres').attr('disabled', 'disabled');
                $('#RepresentativeApellidos').attr('disabled', 'disabled');
            } else {
                $('#juridica').hide("slow");
                $('#natural').hide("slow");
            }
        }
    }
</script>

<legend>EDITAR  PROPONENTE</legend>
<fieldset>
    <?php
    echo $form->create('Proposer');
  
        echo $form->hidden("Proposer.proyect_id");
    echo $form->input("Proposer.id");
    ?>

    <?php
    echo $form->input('Proposer.proposer_type', array('label' => 'Tipo Proponente', 'options' => array(1 => 'Persona Natural', 2 => 'Persona Juridica'), 'empty' => 'Elija opcion', 'id' => 'tipo'));
    ?>
    <div id="juridica">
        <?php
        echo $form->input("Proposer.nombre", array('label' => 'Nombre de la organización', 'id' => 'nom_org'));
        echo $form->input("Proposer.numero_identificacion", array('label' => 'NIT', 'id' => 'ide_org'));
        echo $form->input("Proposer.rep_cedula", array('label' => 'Documento representante legal', 'id' => 'RepresentativeCedula'));
        echo $form->input("Proposer.rep_nombres", array('label' => 'Nombres representante legal', 'id' => 'RepresentativeNombres'));
        echo $form->input("Proposer.rep_apellidos", array('label' => 'Apellidos del representante legal', 'id' => 'RepresentativeApellidos'));
        ?>

    </div>
    <div id="natural">
        <?php
        echo $form->input("Proposer.nombre", array('label' => 'Nombre y Apellidos', 'id' => 'nom_nat'));
        echo $form->input("Proposer.numero_identificacion", array('label' => 'Cedula de ciudadania ', 'id' => 'ide_nat'));
        ?>
    </div>


    <?php
    echo $form->input('Proposer.departament_id', array(
        'label' => __('Departamento', true),
        'empty' => __('Seleccione Departamento', true),
    ));
    ?>
    <?php
    echo $ajax->observeField('ProposerDepartamentId', array(
        'url' => array('action' => 'select'),
        'frequency' => 0.2,
        'update' => 'ciudades'
            )
    );
    ?>

    <div id="ciudades">
        <?php echo $form->input("Proposer.city_id", array('label' => 'Ciudad', 'type' => 'select', 'empty' => 'Seleccione Ciudad')); ?>
    </div>

    <?php
    echo $form->input("Proposer.direccion", array());
    echo $form->input("Proposer.telefono_fijo", array());
    echo $form->input("Proposer.telefono_celular", array());
    echo $form->input("Proposer.fax", array());
    echo $form->input("Proposer.email", array('id'=>'usr'));
    ?>
    <div id="loading" style="display: none;">
        <?php echo $html->image('loading.gif', array('border' => "0", 'align' => 'center')); ?>
    </div>
    <?php
    if ($est == 0)
        echo $ajax->submit('Guardar', array('url' => array('controller' => 'Proposers', 'action' => 'edit',$this->data['Proposer']['id']), 'update' => 'content', 'complete' => 'cargar()', 'indicator' => 'loading'));
    echo $form->end();
    ?>
</fieldset>